﻿using System;

namespace TableCore.Exceptions
{
    public class ValueNotMatchTypeException : Exception
    {
        public static string GetMessage(GTFile.Content content, string data, GTType gttype, string cell)
        {
            return string.Format("\"{0}\" 不能匹配类型 \"{1}\" \n{2}#{3}(单元格: {4})",
                data, gttype.Name, content.File, content.Cmodel.ClassName, cell);
        }

        public static string GenMessage(GTFile.Content content, string data, GTType gttype, int row, int col)
        {
            return GetMessage(content, data, gttype, Utils.GetCellName(row, col));
        }

        public ValueNotMatchTypeException(GTFile.Content content, string data, GTType gttype, int row, int col)
            : base(GenMessage(content, data, gttype, row, col))
        {

        }

        public ValueNotMatchTypeException(GTFile.Content content, string data, GTType gttype, string cell)
            : base(GetMessage(content, data, gttype, cell))
        {

        }

    }

    public class ConvertDataRowException : Exception
    {
        public ConvertDataRowException(string file, string sheet, int row, Exception baseExc)
            : base(string.Format("{0}\n @file:{1}#{2}$ROW[{3}]", baseExc.ToString(), file, sheet, row))
        { }
    }

}
